import 'package:hive/hive.dart';

part 'user_model.g.dart';

@HiveType(typeId: 0)
class UserModel extends HiveObject {
  @HiveField(0)
  String id;

  @HiveField(1)
  String username;

  @HiveField(2)
  String password;

  @HiveField(3)
  String name;

  @HiveField(4)
  String email;

  @HiveField(5)
  String avatar;

  @HiveField(6)
  String description;

  @HiveField(7)
  List<String> followingIds;

  @HiveField(8)
  List<String> followerIds;

  UserModel({
    required this.id,
    required this.username,
    required this.password,
    required this.name,
    required this.email,
    this.avatar = '',
    this.description = '',
    List<String>? followingIds,
    List<String>? followerIds,
  }) : this.followingIds = followingIds ?? [],
       this.followerIds = followerIds ?? [];

  // 辅助方法：检查是否关注了特定用户
  bool isFollowing(String userId) => followingIds.contains(userId);
}
